package com.google.code.chaotic.model;

import java.util.Date;
import java.util.LinkedList;
import java.util.List;

import javax.jdo.annotations.Element;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;

import com.google.code.chaotic.dto.UserType;

//

@PersistenceCapable
public class Commuter extends User {

	{
		userTypeId = UserType.COMMUTER.id;
	}

	/**
	 * @uml.property name="icPassport"
	 */
	@Persistent
	private String icPassport;

	/**
	 * @uml.property name="issuingCountry"
	 */
	@Persistent
	private String issuingCountry;

	/**
	 * @uml.property name="phoneNo"
	 */
	@Persistent
	private String phoneNo;

	/**
	 * @uml.property name="male"
	 */
	@Persistent
	private boolean male;

	/**
	 * @uml.property name="birthDate"
	 */
	@Persistent
	private Date birthDate;

	/**
	 * @uml.property name="membershipStart"
	 */
	@Persistent
	private Date membershipStart;

	/**
	 * @uml.property name="commutingHabits"
	 * @uml.associationEnd multiplicity="(0 -1)" aggregation="composite"
	 *                     inverse=
	 *                     "commuter:com.google.code.chaotic.model.CommutingHabi
	 *                     t
	 */
	@Persistent(mappedBy = "commuter", defaultFetchGroup = "true")
	@Element(dependent = "true")
	private List<CommutingHabit> commutingHabits;

	// // * @uml.property name="commutingServices"
	// // * @uml.associationEnd multiplicity="(0 -1)" aggregation="composite"
	// // * inverse=
	// // * "commuter:com.google.code.chaotic.model.CommutingServic
	// // * e
	// /**
	// * @uml.property name="commutingServices"
	// * @uml.associationEnd multiplicity="(0 -1)"
	// inverse="commuters:com.google.code.chaotic.model.CommutingService"
	// */
	// @ManyToMany(mappedBy = "commuters", targetEntity =
	// CommutingService.class)
	// private List commutingServices = new LinkedList<CommutingService>();

	//

	/** @uml.property name="icPassport" */
	public String getIcPassport() {
		return icPassport;
	}

	/** @uml.property name="icPassport" */
	public void setIcPassport(String icPassport) {
		this.icPassport = icPassport;
	}

	/** @uml.property name="issuingCountry" */
	public void setIssuingCountry(String issuingCountry) {
		this.issuingCountry = issuingCountry;
	}

	/** @uml.property name="issuingCountry" */
	public String getIssuingCountry() {
		return issuingCountry;
	}

	/** @uml.property name="phoneNo" */
	public String getPhoneNo() {
		return phoneNo;
	}

	/** @uml.property name="phoneNo" */
	public void setPhoneNo(String phoneNo) {
		this.phoneNo = phoneNo;
	}

	/** @uml.property name="male" */
	public boolean isMale() {
		return male;
	}

	/** @uml.property name="male" */
	public void setMale(boolean male) {
		this.male = male;
	}

	/** @uml.property name="birthDate" */
	public Date getBirthDate() {
		return birthDate;
	}

	/** @uml.property name="birthDate" */
	public void setBirthDate(Date birthDate) {
		this.birthDate = birthDate;
	}

	/** @uml.property name="membershipStart" */
	public void setMembershipStart(Date membershipStart) {
		this.membershipStart = membershipStart;
	}

	/** @uml.property name="membershipStart" */
	public Date getMembershipStart() {
		return membershipStart;
	}

	/** @uml.property name="commutingHabits" */
	public List<CommutingHabit> getCommutingHabits() {
		return commutingHabits;
	}

	/** @uml.property name="commutingHabits" */
	public void setCommutingHabits(List<CommutingHabit> habits) {
		this.commutingHabits = habits;
	}

	// /**
	// * @uml.property name="commutingServices"
	// */
	// public List<CommutingService> getCommutingServices() {
	// return commutingServices;
	// }
	//	
	// /**
	// * @uml.property name="commutingServices"
	// */
	// public void setCommutingServices(List<CommutingService> services) {
	// this.commutingServices = services;
	// }

	@Override
	public String toString() {
		return String.format( //
				"(IC/Passport: %1$s - %2$s)", //
				icPassport, issuingCountry);
	}

}
